home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1387 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.9 KB

  1. Path: kbad.eglin.af.mil!rpi!not-for-mail
  2. From: floydb1@lib104.its.rpi.edu (Barry B Floyd)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Virtual functions in derived classes
  5. Date: 10 Jan 1996 10:26:19 -0500
  6. Organization: Rensselaer Polytechnic Institute, Troy, NY.
  7. Message-ID: <4d0lqr$aa8@lib104.its.rpi.edu>
  8. References: <30ECA10F.3D99@ifu.net> <NITIN.96Jan5125830@more.eng.sun.com>  <4crquj$7t1@lib108.its.rpi.edu> <NITIN.96Jan9103242@more.eng.sun.com>  <ALUN.CHAMPION.96Jan9152102@g7240065.bridge.bst.bls.com> <NITIN.96Jan9170606@more.eng.sun.com>
  9. NNTP-Posting-Host: lib104.its.rpi.edu
  10. X-newsreader: xrn 7.04-beta-11
  11.  
  12.  
  13. In article <NITIN.96Jan9170606@more.eng.sun.com>, nitin@more.eng.sun.com (Nitin More [CONTRACTOR]) writes:
  14. > Alan,
  15. > Thanks for clarifying that ...
  16. > > If a virtual member function vf is declared in a class Base and in a
  17.     class
  18. > > Derived, derived directly or indirectly from Base, a member function 
  19.     vf with
  20. > > the same name and same parameter list as Base::vf is declared, then
  21. > > Derived::vf is also virtual (whether or not it is so declared) and it
  22. > > overrides Base::vf. ...
  23. > > ...
  24. > This is Yuck!  since sometimes you might not want the user of your 
  25.     class
  26. > library to overwrite your methods but want to use the virtual methods 
  27. > in implementing the class library.  
  28. > -Nitin
  29.  
  30. The user is the one providing the method's code, the librarian is
  31. only declaring that the function must exist in order to conform to 
  32. the requirements of the entire class.
  33.  
  34.           Base::Function ( int, int ) = 0 ;     // no implementation.
  35. DerivedDerived::Function ( int, int ) ;        // inherits...
  36.        Derived::Function ( int, int ) {code} ;    // when implemented.
  37.  
  38. -- 
  39. +--------------------------------------------------------------------+ 
  40. | Barry B. Floyd                   \\\               floydb1@rpi.edu |
  41. | RPI Alum. '84 '87 '88              \\\                             |
  42. +--------------------------------------------------------------------+
  43.